<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8" />
	<title>千郡医疗-添加代理</title>
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<meta name="format-detection" content="telephone=no" />
	<link rel="stylesheet" th:href="@{/weixin/css/weui.min.css}" />
	<link rel="stylesheet" th:href="@{/weixin/css/style.css}" />
    <script type="text/javascript"  th:src="@{/weixin/js/adaptive.js}"></script>
	<script type="text/javascript"  th:src="@{/weixin/js/fastclick.min.js}"></script>
	<script type="text/javascript"  th:src="@{/weixin/js/zepto.min.js}"></script>
	<script type="text/javascript" th:src="@{/weixin/js/weui.min.js}"></script>
</head>
<body>
	<section class="agentPage">
	<form id="form">
		<ul>
			<li>
				<p>姓名</p>
				<p><input type="text" name="name" id="name" class="txt" placeholder="请输入代理姓名" /></p>
			</li>
			<li>
				<p>手机号码</p>
				<p><input type="tel" name="phoneNo" id="phoneNo" class="txt" placeholder="输入代理电话号码" /></p>
			</li>
		</ul>
		<p class="btm">
			<a href="javascript:;" id="submit" class="comBtn">添加</a>
		</p>
	</form>
	</section>
</body>
<script type="text/javascript">
		$(function(){
			FastClick.attach(document.body);
			$("#submit").click(submit);
		});
		
		function submit() {
			if (!validate())
				return;

			var l = weui.loading("正在提交")
			$.ajax({
				cache : true,
				type : "POST",
				url : "/qianjun/weixin/customer/addagent",
				data : $('#form').serialize(),
				error : function(request) {
					l.hide();
					weui.alert("Connection error");
				},
				success : function(data) {
					l.hide();
					if (data.success){
	                    window.location.href =  "/qianjun/weixin/customer/agent";
						return;
					}
					weui.alert(data.msg);
				}
			});
		}
		
		function validate() {
			if($("#name").val() == ''){
				weui.alert("名字不能为空");
				return false;
			}
			
			if(!(/^1[34578]\d{9}$/.test($("#phoneNo").val()))){ 
		        weui.alert("请输入正确的手机号码");  
		        return false; 
		    } 

			return true;
		}
	</script>
</html>